package edu.gatech.coc.sirana.detection;

import java.util.ArrayList;

import net.util.Debug;

public class StringHammingDistance {
	public double computeNormalizedHD(ArrayList<String> s1, ArrayList<String> s2){
		int l1 = s1.size();
		int l2 = s2.size();
		
		int compBound = Math.min(l1, l2);
		int lengthDiff = Math.abs(l2-l1);
		
		
		for (int compIndex = 0; compIndex < compBound; compIndex++){
			String _1 = s1.get(compIndex);
			String _2 = s2.get(compIndex);
			
			if (!_1.equals(_2)){
				lengthDiff++;
			}
		}
		
		double normHD = (double) lengthDiff/(l1+l2);//Math.max(l1, l2);

//		Debug.println("***computing nhd:\n" + s1.toString() + "\n" + s2.toString());
//		Debug.println("normHD=" + normHD + "\n");
		return normHD;
	}
}
